package kernel.db.basics;


import java.sql.SQLException;
import java.sql.ResultSet;

public class Piece extends DBOperator{

	/* ############################### Fields ############################### */
	private int IdPiece;

	private String NomPiece;

	/* ############################### Getters ############################## */
	public int getIdPiece(){
		return IdPiece;
	}

	public String getNomPiece(){
		return NomPiece;
	}

	/* ############################### Setters ############################## */
	public void setIdPiece(int newValue){
		this.IdPiece = newValue;
	}

	public void setNomPiece(String newValue){
		this.NomPiece = newValue;
	}

	/* ########################### CLASS CONSTRUCTORS ####################### */
	public Piece(String NomPiece) throws SQLException {
		this.NomPiece = NomPiece;
		this.IdPiece = executeUpdate("INSERT INTO piece VALUES('DEFAULT','"+NomPiece+"')");
	}

	public Piece(int IdPiece) throws SQLException {
		ResultSet rs = executeSelect("SELECT * FROM piece WHERE IdPiece='"+IdPiece+"'");
				this.IdPiece = rs.getInt(IdPiece);

	}
}